package com.alibaba.druid.bvt.filter.wall;

import com.alibaba.druid.wall.WallProvider;
import com.alibaba.druid.wall.WallTableStat;
import com.alibaba.druid.wall.spi.MySqlWallProvider;
import com.alibaba.druid.wall.spi.OracleWallProvider;
import junit.framework.TestCase;

public class WallStatTest_alter_table extends TestCase {
    public void testMySql() throws Exception {
        String sql = "alter table t add column fname varchar(50)";
        WallProvider provider = new MySqlWallProvider();
        provider.getConfig().setAlterTableAllow(true);

        assertTrue(provider.checkValid(sql));
        WallTableStat tableStat = provider.getTableStat("t");
        assertEquals(1, tableStat.getAlterCount());
    }

    public void testOracle() throws Exception {
        String sql = "alter table t add (fname varchar(50))";
        WallProvider provider = new OracleWallProvider();
        provider.getConfig().setAlterTableAllow(true);

        assertTrue(provider.checkValid(sql));
        WallTableStat tableStat = provider.getTableStat("t");
        assertEquals(1, tableStat.getAlterCount());
    }

//    public void testPG() throws Exception {
//        WallProvider provider = new PGWallProvider();
//        provider.getConfig().setAlterTableAllow(true);
//
//        assertTrue(provider.checkValid(sql));
//        WallTableStat tableStat = provider.getTableStat("t");
//        assertEquals(1, tableStat.getAlterCount());
//    }
//
//    public void testSQLServer() throws Exception {
//        WallProvider provider = new SQLServerWallProvider();
//        provider.getConfig().setAlterTableAllow(true);
//
//        assertTrue(provider.checkValid(sql));
//        WallTableStat tableStat = provider.getTableStat("t");
//        assertEquals(1, tableStat.getAlterCount());
//    }
}
